<template>
  <div class="custom-body" :style="borderStyle">
    <el-empty v-if="dataList === null || dataList.length === 0" :image-size="100" />
    <el-carousel v-else height="100%" class="custom-carousel">
      <el-carousel-item v-for="item in dataList" :key="'carousel-'+item.number">
        <carousel-item :number="item.number" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import CarouselItem from './slot/item';
export default {
  name: 'PcCarouselTempV1',
  components: { CarouselItem },
  props: {
    temp: {
      type: Object,
      default() {
        return {};
      }
    },
    showHeader: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      setting: null,
      dataList: [],
      borderStyle: {}
    };
  },
  computed: {
    themes() {
      return this.$store.getters.theme;
    }
  },
  watch: {
    temp: {
      handler(newData, oldData) {
        if (this.showHeader === true) {
          const pzx = JSON.parse(newData.data.pzx);
          this.setting = pzx;
        } else {
          const pzx = JSON.parse(newData.pzx);
          this.setting = pzx;
        }
        if (undefined !== this.setting.data) {
          this.dataList = this.setting.data;
        } else {
          this.dataList = [];
        }
      },
      immediate: true, // 父组件第一次传值时，执行handler，false则第一次不执行
      deep: false // formType为对象时，设置为true，此属性监听对象发生变化
    },
    themes: {
      handler(val, old) {
        this.borderStyle.borderRadius = val.bkdx;
        if (this.temp.sfxsbk === true) {
          this.borderStyle.border = '1px solid ' + val.bkys;
        }
        if (this.temp.bkyy === true) {
          this.borderStyle.boxShadow = '0 2px 4px rgba(0, 0, 0, .12)';
        }
        this.borderStyle.background = val.columnGroundColor;
        this.borderStyle.color = val.fontColor;
        this.borderStyle = Object.assign({}, this.borderStyle);
      },
      immediate: true, // 父组件第一次传值时，执行handler，false则第一次不执行
      deep: false // formType为对象时，设置为true，此属性监听对象发生变化
    }
  }
};
</script>

<style scoped>
.custom-body {
  width: 100%;
  height: 100%;
  position: relative;
  background-color: #ffffff;
  border-radius: 4px;
  overflow: hidden;
}
.custom-carousel {
  height: 100% !important;
}
</style>
